package com.xinchen.aiowaste.base

import com.maple.model.resp.BaseResp
import com.maple.utils.util.LogUtils
import com.xinchen.aiowaste.model.repository.ResultCode
import com.maple.base.viewModel.BaseVM as Base

abstract class BaseViewModel: Base() {
    override fun isSuccess(resp: BaseResp): Boolean = ResultCode.isSuccess(resp.code)


    private var pageNum: Long = 0
    fun getPageNum(): Long {
        return pageNum
    }

    fun resetPage() {
        this.pageNum = 0
    }

    fun nextPage() {
        this.pageNum += 1
    }

    private var hasNoMoreData: Boolean = false

    fun getNoMoreData(): Boolean {
        return hasNoMoreData
    }

    fun setNoMoreData(total: Long? = 0) {
        LogUtils.logGGQ("setNoMoreData:${total}")
        this.hasNoMoreData = (total != getPageNum())
    }
}